package com.demo.spark.rdd

import org.apache.spark.{SparkConf, SparkContext}

object RddMapScala {
  def main(args: Array[String]): Unit = {
    val config = new SparkConf().setAppName("rdd scala map").setMaster("local");
    val sparkcontext = SparkContext.getOrCreate(config);
    val rdd = sparkcontext.parallelize(List(1, 2, 3, 4, 5))
    val square = rdd.map(x => x * x)
    val intArr = square.collect()
    intArr.foreach(line => println(line))
  }

}
